package com.deyang.workflow.service.impl;

import com.deyang.workflow.entity.WorkOrderStep;
import com.deyang.workflow.mapper.WorkOrderStepMapper;
import com.deyang.workflow.service.IWorkOrderStepService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 模板步骤表 服务实现类
 * </p>
 *
 * @author zhanghuaiyu
 * @since 2021-07-01
 */
@Service
@Transactional
public class WorkOrderStepServiceImpl extends ServiceImpl<WorkOrderStepMapper, WorkOrderStep> implements IWorkOrderStepService {

    @Autowired
    private WorkOrderStepMapper workOrderStepMapper;


    @Override
    public void editTemplate(List<WorkOrderStep> list) {
        if (null != list && list.size() > 0) {
            try {
                for (WorkOrderStep workOrderStep : list) {
                    //1.状态为1的代表删除记录
                    if ("1".equals(workOrderStep.getDeleteStatus())) {
                        workOrderStep.setStatus("0");
                        workOrderStepMapper.updateById(workOrderStep);
                    }

                    //状态为0的代表编辑
                    if ("0".equals(workOrderStep.getDeleteStatus())) {
                        workOrderStepMapper.updateById(workOrderStep);
                    }
                }
            } catch (Exception e) {
                log.error("==========================" + "模板步骤表修改失败"+e.getMessage());
            }
        }
    }
}
